<?php
/* Match & impression & click log */
$pv_id = $_COOKIE['pv_id'];
$data['pv_id'] = $pv_id;
$data['time_stamp'] = $_SERVER['REQUEST_TIME'].'';
$type = $_REQUEST['type'];
//if (!in_array($type, array('img_match','kw_match','impression','click')) || !$pv_id) die();
if (!in_array($type, array('img_match','kw_match','impression','click'))) die();
$data = array_merge($_GET, $_POST, $data);
if (isset($data['pageurl'])) {
    $data['page_url'] = $data['pageurl'];
    unset($data['pageurl']);
}
if (!$pv_id && !isset($data['page_url'])) $data['page_url'] = $_SERVER['HTTP_REFERER'];//backup logic for no pv_id
apache_note('tracking_log', json_encode($data));
